package com.lzc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzc.pojo.entity.Friend;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FriendMapper extends BaseMapper<Friend> {

    @Select("select * from friends where user_id = #{sid} and friend_id = (select user_id from friends where user_id = #{rid} and friend_id = #{sid})")
    public Friend isFriend(@Param("sid") Long sid, @Param("rid") Long rid);

    @Select("select friend_id from friends where user_id = #{userId} and friend_id in (select user_id from friends where friend_id = #{userId})")
    public List<Long> findFriends(@Param("userId") Long userId);
}
